.port-bindings
  %h4 Mapped Endpoints

  %table.port-bindings
    %colgroup
      %col.ports
      %col
      %col.actions
    %thead
      %tr
        %th
          host : container / protocol
        %th
          mapped endpoint
        %th
    %tbody
      = f.fields_for :ports do |port|
        - checkbox_id = "select_port_binding_#{port.options[:child_index]}"
        %tr{class: port.object.host_port.blank? ?  'auto-assigned-host' : ''}
          %td{title: "host: #{port.object.host_port},
                      container: #{port.object.container_port},
                      protocol: #{port.object.proto}"}
            %span.host-port= port.object.host_port
            \:
            %span.container-port= port.object.container_port
            \/
            %span.proto= port.object.proto
          %td.mapped-endpoint-link
            %span.path
            = link_to "#{request.env['SERVER_NAME']}:#{port.object.host_port}",
                      "#{request.env['SERVER_NAME']}:#{port.object.host_port}",
                      target: 'blank',
                      class: 'view-action',
                      data: {host: request.env['SERVER_NAME']}
          %td
            .actions
              = port.check_box :_deleted, { id: checkbox_id }
              = port.hidden_field :container_port
              = port.hidden_field :host_port
              = port.hidden_field :proto
              %a{class: 'delete-action', title: 'remove', data: { checkbox: { selector: "##{checkbox_id}" } } } remove

  %ul.additional-entries
    %li.editing
      = add_fields_for(:ports, f, { child_index: '_replaceme_' }) do |builder|
        = builder.number_field :host_port, disabled: true, placeholder: 'host', title: 'host', min: 0, class: 'host-port'
        = ':'
        = builder.number_field :container_port, disabled: true, placeholder: 'container', title: 'container', min: 0, class: 'container-port'
        = '/'
        = builder.select :proto, options_for_select(['TCP', 'UDP']), {}, disabled: true, title: 'Protocol', class: 'proto'
        %a.cancel Cancel
        .optional leave host blank for auto assignment

  %a.button-add Bind a Port
